from time import *
f1 = [int(i) for i in open('m1_sorted.txt', 'r').read().split()]
f2 = [int(i) for i in open('m2_reverse.txt', 'r').read().split()]
f3 = [int(i) for i in open('m3_shuffle.txt', 'r').read().split()]

def puzir(a):
    t_start = time()
    for j in range(1,len(a)):
        for i in range(0,len(a)-j):
            if a[i]>a[i+1]:
                a[i], a[i+1]=  a[i+1],a[i]

    t_finish = time()
    return (t_finish - t_start)




print(round(puzir(f1))*1000)
print(round(puzir(f2))*1000)
print(round(puzir(f3))*1000)
